﻿Imports System.Data.SqlClient
Imports System.Data
Imports System.Data.Sql
Imports BUS
Imports DTO

Public Class frmDangNhap

    Private Sub btt_Thoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btt_Thoat.Click
        Me.Close()
    End Sub
    Private Sub btt_dangnhap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btt_dangnhap.Click
        Dim NguoiDung As DangNhapDTO
        Dim username As String
        Dim password As String
        If (txt_pass.Text = String.Empty) Then
            lablecheck.Text = "Chưa nhập mật khẩu? "
            txt_pass.Focus()
            Return
        End If

        password = txt_pass.Text
        NguoiDung = DangNhapBUS.GetByID(username)

        If NguoiDung.TenDN = String.Empty Then
            lablecheck.Text = "Không tồn tại tài khoản này"
            Return
        End If

        If NguoiDung.MatKhau <> password Then
            lablecheck.Text = "Mật khẩu không đúng"
            Return
        End If

        If NguoiDung.TrangThai = 1 Then
            lablecheck.Text = "Tài khoản của bạn đã bị Xóa"
            Return
        End If

        If NguoiDung.Quyen = "Admin" Then
            frmMain.Show()
        Else
            frmMain.NhanVien()
        End If
        Me.Close()

    End Sub

    Private Sub ComboBoxEx1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub
End Class